﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp_1209
{
    class Product
    {
        public static void Test()
        {
            // Accepting and converting the details of the products
            // into reference types using implicit boxing
            Console.Write("Enter the id of product : ");
            // object = int32
            object objProductID = Convert.ToInt32(Console.ReadLine());
            
            Console.Write("Enter the name of product : ");
            object objProductName = Console.ReadLine();

            Console.Write("Enter price : ");
            object objPrice = Convert.ToDouble(Console.ReadLine());
            
            Console.Write("Enter quantity : ");
            object objQuantity = Convert.ToInt32(Console.ReadLine());

            // Converting objects into their relevant types 
            // using explicit unboxing
            //            int ProductID = objProductID;   // Error occurs while unboxing

            int productId = (int)objProductID;
            string productName = (string)objProductName;
            double price = (double)objPrice;
            int quantity = (int)objQuantity;
            double amtPayable = (int)objQuantity * price;

            // Displaying the details of the product
            Console.WriteLine("\nProduct Details:");
            Console.WriteLine("Product ID : " + productId);
            Console.WriteLine("Product Name : " + productName);
            Console.WriteLine("Price : {0:C2}", price);
            Console.WriteLine("Quantity : " + quantity);
            Console.WriteLine("Amt Payable {0:F2}: ", amtPayable);
        }
    }
}
